package browser;

import com.example.android.R;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ExemploAbrirBrowser extends Activity implements OnClickListener {
	Button botaoOk;
	EditText campoEndereco;

	public void onCreate(Bundle b) {
		super.onCreate(b);
		setContentView(R.layout.form_browser);
		botaoOk = (Button) findViewById(R.id.botaoOK);
		campoEndereco = (EditText) findViewById(R.id.campoEndereco);
		botaoOk.setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		if (arg0 == botaoOk) {
			String endereco = campoEndereco.getText().toString();
			// Representa o endereco que desejamos abrir
			Uri uri = Uri.parse(endereco);
			// Cria a intent com o endereco
			Intent intent = new Intent(Intent.ACTION_VIEW, uri);
			startActivity(intent);
		}
	}
}
